<?php


/**
 * Base class that represents a query for the 'estimated_budgets' table.
 *
 *
 *
 * @method DamagesEstimatedBudgetsQuery orderById($order = Criteria::ASC) Order by the id column
 * @method DamagesEstimatedBudgetsQuery orderByCarDamageId($order = Criteria::ASC) Order by the car_damage_id column
 * @method DamagesEstimatedBudgetsQuery orderByAttachmentId($order = Criteria::ASC) Order by the attachment_id column
 * @method DamagesEstimatedBudgetsQuery orderByValue($order = Criteria::ASC) Order by the value column
 * @method DamagesEstimatedBudgetsQuery orderByDiscountFlag($order = Criteria::ASC) Order by the discount_flag column
 * @method DamagesEstimatedBudgetsQuery orderByDiscountValue($order = Criteria::ASC) Order by the discount_value column
 * @method DamagesEstimatedBudgetsQuery orderByDiscountPercentage($order = Criteria::ASC) Order by the discount_percentage column
 * @method DamagesEstimatedBudgetsQuery orderByCarValue($order = Criteria::ASC) Order by the car_value column
 * @method DamagesEstimatedBudgetsQuery orderByDeductionValue($order = Criteria::ASC) Order by the deduction_value column
 * @method DamagesEstimatedBudgetsQuery orderByIsDefault($order = Criteria::ASC) Order by the is_default column
 * @method DamagesEstimatedBudgetsQuery orderByCreated($order = Criteria::ASC) Order by the created column
 * @method DamagesEstimatedBudgetsQuery orderByModified($order = Criteria::ASC) Order by the modified column
 *
 * @method DamagesEstimatedBudgetsQuery groupById() Group by the id column
 * @method DamagesEstimatedBudgetsQuery groupByCarDamageId() Group by the car_damage_id column
 * @method DamagesEstimatedBudgetsQuery groupByAttachmentId() Group by the attachment_id column
 * @method DamagesEstimatedBudgetsQuery groupByValue() Group by the value column
 * @method DamagesEstimatedBudgetsQuery groupByDiscountFlag() Group by the discount_flag column
 * @method DamagesEstimatedBudgetsQuery groupByDiscountValue() Group by the discount_value column
 * @method DamagesEstimatedBudgetsQuery groupByDiscountPercentage() Group by the discount_percentage column
 * @method DamagesEstimatedBudgetsQuery groupByCarValue() Group by the car_value column
 * @method DamagesEstimatedBudgetsQuery groupByDeductionValue() Group by the deduction_value column
 * @method DamagesEstimatedBudgetsQuery groupByIsDefault() Group by the is_default column
 * @method DamagesEstimatedBudgetsQuery groupByCreated() Group by the created column
 * @method DamagesEstimatedBudgetsQuery groupByModified() Group by the modified column
 *
 * @method DamagesEstimatedBudgetsQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method DamagesEstimatedBudgetsQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method DamagesEstimatedBudgetsQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method DamagesEstimatedBudgetsQuery leftJoinCarDamages($relationAlias = null) Adds a LEFT JOIN clause to the query using the CarDamages relation
 * @method DamagesEstimatedBudgetsQuery rightJoinCarDamages($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CarDamages relation
 * @method DamagesEstimatedBudgetsQuery innerJoinCarDamages($relationAlias = null) Adds a INNER JOIN clause to the query using the CarDamages relation
 *
 * @method DamagesEstimatedBudgetsQuery leftJoinAttachments($relationAlias = null) Adds a LEFT JOIN clause to the query using the Attachments relation
 * @method DamagesEstimatedBudgetsQuery rightJoinAttachments($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Attachments relation
 * @method DamagesEstimatedBudgetsQuery innerJoinAttachments($relationAlias = null) Adds a INNER JOIN clause to the query using the Attachments relation
 *
 * @method DamagesEstimatedBudgets findOne(PropelPDO $con = null) Return the first DamagesEstimatedBudgets matching the query
 * @method DamagesEstimatedBudgets findOneOrCreate(PropelPDO $con = null) Return the first DamagesEstimatedBudgets matching the query, or a new DamagesEstimatedBudgets object populated from the query conditions when no match is found
 *
 * @method DamagesEstimatedBudgets findOneById(int $id) Return the first DamagesEstimatedBudgets filtered by the id column
 * @method DamagesEstimatedBudgets findOneByCarDamageId(int $car_damage_id) Return the first DamagesEstimatedBudgets filtered by the car_damage_id column
 * @method DamagesEstimatedBudgets findOneByAttachmentId(int $attachment_id) Return the first DamagesEstimatedBudgets filtered by the attachment_id column
 * @method DamagesEstimatedBudgets findOneByValue(string $value) Return the first DamagesEstimatedBudgets filtered by the value column
 * @method DamagesEstimatedBudgets findOneByDiscountFlag(int $discount_flag) Return the first DamagesEstimatedBudgets filtered by the discount_flag column
 * @method DamagesEstimatedBudgets findOneByDiscountValue(string $discount_value) Return the first DamagesEstimatedBudgets filtered by the discount_value column
 * @method DamagesEstimatedBudgets findOneByDiscountPercentage(string $discount_percentage) Return the first DamagesEstimatedBudgets filtered by the discount_percentage column
 * @method DamagesEstimatedBudgets findOneByCarValue(string $car_value) Return the first DamagesEstimatedBudgets filtered by the car_value column
 * @method DamagesEstimatedBudgets findOneByDeductionValue(string $deduction_value) Return the first DamagesEstimatedBudgets filtered by the deduction_value column
 * @method DamagesEstimatedBudgets findOneByIsDefault(int $is_default) Return the first DamagesEstimatedBudgets filtered by the is_default column
 * @method DamagesEstimatedBudgets findOneByCreated(string $created) Return the first DamagesEstimatedBudgets filtered by the created column
 * @method DamagesEstimatedBudgets findOneByModified(string $modified) Return the first DamagesEstimatedBudgets filtered by the modified column
 *
 * @method array findById(int $id) Return DamagesEstimatedBudgets objects filtered by the id column
 * @method array findByCarDamageId(int $car_damage_id) Return DamagesEstimatedBudgets objects filtered by the car_damage_id column
 * @method array findByAttachmentId(int $attachment_id) Return DamagesEstimatedBudgets objects filtered by the attachment_id column
 * @method array findByValue(string $value) Return DamagesEstimatedBudgets objects filtered by the value column
 * @method array findByDiscountFlag(int $discount_flag) Return DamagesEstimatedBudgets objects filtered by the discount_flag column
 * @method array findByDiscountValue(string $discount_value) Return DamagesEstimatedBudgets objects filtered by the discount_value column
 * @method array findByDiscountPercentage(string $discount_percentage) Return DamagesEstimatedBudgets objects filtered by the discount_percentage column
 * @method array findByCarValue(string $car_value) Return DamagesEstimatedBudgets objects filtered by the car_value column
 * @method array findByDeductionValue(string $deduction_value) Return DamagesEstimatedBudgets objects filtered by the deduction_value column
 * @method array findByIsDefault(int $is_default) Return DamagesEstimatedBudgets objects filtered by the is_default column
 * @method array findByCreated(string $created) Return DamagesEstimatedBudgets objects filtered by the created column
 * @method array findByModified(string $modified) Return DamagesEstimatedBudgets objects filtered by the modified column
 *
 * @package    propel.generator.damages.om
 */
abstract class DamagesBaseEstimatedBudgetsQuery extends ModelCriteria
{
    /**
     * Initializes internal state of DamagesBaseEstimatedBudgetsQuery object.
     *
     * @param     string $dbName The dabase name
     * @param     string $modelName The phpName of a model, e.g. 'Book'
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     */
    public function __construct($dbName = 'vgp_damages', $modelName = 'DamagesEstimatedBudgets', $modelAlias = null)
    {
        parent::__construct($dbName, $modelName, $modelAlias);
    }

    /**
     * Returns a new DamagesEstimatedBudgetsQuery object.
     *
     * @param     string $modelAlias The alias of a model in the query
     * @param     DamagesEstimatedBudgetsQuery|Criteria $criteria Optional Criteria to build the query from
     *
     * @return DamagesEstimatedBudgetsQuery
     */
    public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof DamagesEstimatedBudgetsQuery) {
            return $criteria;
        }
        $query = new DamagesEstimatedBudgetsQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }

    /**
     * Find object by primary key.
     * Propel uses the instance pool to skip the database if the object exists.
     * Go fast if the query is untouched.
     *
     * <code>
     * $obj  = $c->findPk(12, $con);
     * </code>
     *
     * @param mixed $key Primary key to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return   DamagesEstimatedBudgets|DamagesEstimatedBudgets[]|mixed the result, formatted by the current formatter
     */
    public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = DamagesEstimatedBudgetsPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
            // the object is alredy in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getConnection(DamagesEstimatedBudgetsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

    /**
     * Find object by primary key using raw SQL to go fast.
     * Bypass doSelect() and the object formatter by using generated code.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return   DamagesEstimatedBudgets A model object, or null if the key is not found
     * @throws   PropelException
     */
    protected function findPkSimple($key, $con)
    {
        $sql = 'SELECT ID, CAR_DAMAGE_ID, ATTACHMENT_ID, VALUE, DISCOUNT_FLAG, DISCOUNT_VALUE, DISCOUNT_PERCENTAGE, CAR_VALUE, DEDUCTION_VALUE, IS_DEFAULT, CREATED, MODIFIED FROM estimated_budgets WHERE ID = :p0';
        try {
            $stmt = $con->prepare($sql);
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
        }
        $obj = null;
        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $obj = new DamagesEstimatedBudgets();
            $obj->hydrate($row);
            DamagesEstimatedBudgetsPeer::addInstanceToPool($obj, (string) $key);
        }
        $stmt->closeCursor();

        return $obj;
    }

    /**
     * Find object by primary key.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return DamagesEstimatedBudgets|DamagesEstimatedBudgets[]|mixed the result, formatted by the current formatter
     */
    protected function findPkComplex($key, $con)
    {
        // As the query uses a PK condition, no limit(1) is necessary.
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKey($key)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    }

    /**
     * Find objects by primary key
     * <code>
     * $objs = $c->findPks(array(12, 56, 832), $con);
     * </code>
     * @param     array $keys Primary keys to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return PropelObjectCollection|DamagesEstimatedBudgets[]|mixed the list of results, formatted by the current formatter
     */
    public function findPks($keys, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKeys($keys)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->format($stmt);
    }

    /**
     * Filter the query by primary key
     *
     * @param     mixed $key Primary key to use for the query
     *
     * @return DamagesEstimatedBudgetsQuery The current query, for fluid interface
     */
    public function filterByPrimaryKey($key)
    {

        return $this->addUsingAlias(DamagesEstimatedBudgetsPeer::ID, $key, Criteria::EQUAL);
    }

    /**
     * Filter the query by a list of primary keys
     *
     * @param     array $keys The list of primary key to use for the query
     *
     * @return DamagesEstimatedBudgetsQuery The current query, for fluid interface
     */
    public function filterByPrimaryKeys($keys)
    {

        return $this->addUsingAlias(DamagesEstimatedBudgetsPeer::ID, $keys, Criteria::IN);
    }

    /**
     * Filter the query on the id column
     *
     * Example usage:
     * <code>
     * $query->filterById(1234); // WHERE id = 1234
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
     * $query->filterById(array('min' => 12)); // WHERE id > 12
     * </code>
     *
     * @param     mixed $id The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesEstimatedBudgetsQuery The current query, for fluid interface
     */
    public function filterById($id = null, $comparison = null)
    {
        if (is_array($id) && null === $comparison) {
            $comparison = Criteria::IN;
        }

        return $this->addUsingAlias(DamagesEstimatedBudgetsPeer::ID, $id, $comparison);
    }

    /**
     * Filter the query on the car_damage_id column
     *
     * Example usage:
     * <code>
     * $query->filterByCarDamageId(1234); // WHERE car_damage_id = 1234
     * $query->filterByCarDamageId(array(12, 34)); // WHERE car_damage_id IN (12, 34)
     * $query->filterByCarDamageId(array('min' => 12)); // WHERE car_damage_id > 12
     * </code>
     *
     * @see       filterByCarDamages()
     *
     * @param     mixed $carDamageId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesEstimatedBudgetsQuery The current query, for fluid interface
     */
    public function filterByCarDamageId($carDamageId = null, $comparison = null)
    {
        if (is_array($carDamageId)) {
            $useMinMax = false;
            if (isset($carDamageId['min'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::CAR_DAMAGE_ID, $carDamageId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($carDamageId['max'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::CAR_DAMAGE_ID, $carDamageId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesEstimatedBudgetsPeer::CAR_DAMAGE_ID, $carDamageId, $comparison);
    }

    /**
     * Filter the query on the attachment_id column
     *
     * Example usage:
     * <code>
     * $query->filterByAttachmentId(1234); // WHERE attachment_id = 1234
     * $query->filterByAttachmentId(array(12, 34)); // WHERE attachment_id IN (12, 34)
     * $query->filterByAttachmentId(array('min' => 12)); // WHERE attachment_id > 12
     * </code>
     *
     * @see       filterByAttachments()
     *
     * @param     mixed $attachmentId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesEstimatedBudgetsQuery The current query, for fluid interface
     */
    public function filterByAttachmentId($attachmentId = null, $comparison = null)
    {
        if (is_array($attachmentId)) {
            $useMinMax = false;
            if (isset($attachmentId['min'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::ATTACHMENT_ID, $attachmentId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($attachmentId['max'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::ATTACHMENT_ID, $attachmentId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesEstimatedBudgetsPeer::ATTACHMENT_ID, $attachmentId, $comparison);
    }

    /**
     * Filter the query on the value column
     *
     * Example usage:
     * <code>
     * $query->filterByValue(1234); // WHERE value = 1234
     * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34)
     * $query->filterByValue(array('min' => 12)); // WHERE value > 12
     * </code>
     *
     * @param     mixed $value The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesEstimatedBudgetsQuery The current query, for fluid interface
     */
    public function filterByValue($value = null, $comparison = null)
    {
        if (is_array($value)) {
            $useMinMax = false;
            if (isset($value['min'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::VALUE, $value['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($value['max'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::VALUE, $value['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesEstimatedBudgetsPeer::VALUE, $value, $comparison);
    }

    /**
     * Filter the query on the discount_flag column
     *
     * Example usage:
     * <code>
     * $query->filterByDiscountFlag(1234); // WHERE discount_flag = 1234
     * $query->filterByDiscountFlag(array(12, 34)); // WHERE discount_flag IN (12, 34)
     * $query->filterByDiscountFlag(array('min' => 12)); // WHERE discount_flag > 12
     * </code>
     *
     * @param     mixed $discountFlag The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesEstimatedBudgetsQuery The current query, for fluid interface
     */
    public function filterByDiscountFlag($discountFlag = null, $comparison = null)
    {
        if (is_array($discountFlag)) {
            $useMinMax = false;
            if (isset($discountFlag['min'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::DISCOUNT_FLAG, $discountFlag['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($discountFlag['max'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::DISCOUNT_FLAG, $discountFlag['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesEstimatedBudgetsPeer::DISCOUNT_FLAG, $discountFlag, $comparison);
    }

    /**
     * Filter the query on the discount_value column
     *
     * Example usage:
     * <code>
     * $query->filterByDiscountValue(1234); // WHERE discount_value = 1234
     * $query->filterByDiscountValue(array(12, 34)); // WHERE discount_value IN (12, 34)
     * $query->filterByDiscountValue(array('min' => 12)); // WHERE discount_value > 12
     * </code>
     *
     * @param     mixed $discountValue The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesEstimatedBudgetsQuery The current query, for fluid interface
     */
    public function filterByDiscountValue($discountValue = null, $comparison = null)
    {
        if (is_array($discountValue)) {
            $useMinMax = false;
            if (isset($discountValue['min'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::DISCOUNT_VALUE, $discountValue['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($discountValue['max'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::DISCOUNT_VALUE, $discountValue['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesEstimatedBudgetsPeer::DISCOUNT_VALUE, $discountValue, $comparison);
    }

    /**
     * Filter the query on the discount_percentage column
     *
     * Example usage:
     * <code>
     * $query->filterByDiscountPercentage(1234); // WHERE discount_percentage = 1234
     * $query->filterByDiscountPercentage(array(12, 34)); // WHERE discount_percentage IN (12, 34)
     * $query->filterByDiscountPercentage(array('min' => 12)); // WHERE discount_percentage > 12
     * </code>
     *
     * @param     mixed $discountPercentage The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesEstimatedBudgetsQuery The current query, for fluid interface
     */
    public function filterByDiscountPercentage($discountPercentage = null, $comparison = null)
    {
        if (is_array($discountPercentage)) {
            $useMinMax = false;
            if (isset($discountPercentage['min'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::DISCOUNT_PERCENTAGE, $discountPercentage['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($discountPercentage['max'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::DISCOUNT_PERCENTAGE, $discountPercentage['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesEstimatedBudgetsPeer::DISCOUNT_PERCENTAGE, $discountPercentage, $comparison);
    }

    /**
     * Filter the query on the car_value column
     *
     * Example usage:
     * <code>
     * $query->filterByCarValue(1234); // WHERE car_value = 1234
     * $query->filterByCarValue(array(12, 34)); // WHERE car_value IN (12, 34)
     * $query->filterByCarValue(array('min' => 12)); // WHERE car_value > 12
     * </code>
     *
     * @param     mixed $carValue The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesEstimatedBudgetsQuery The current query, for fluid interface
     */
    public function filterByCarValue($carValue = null, $comparison = null)
    {
        if (is_array($carValue)) {
            $useMinMax = false;
            if (isset($carValue['min'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::CAR_VALUE, $carValue['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($carValue['max'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::CAR_VALUE, $carValue['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesEstimatedBudgetsPeer::CAR_VALUE, $carValue, $comparison);
    }

    /**
     * Filter the query on the deduction_value column
     *
     * Example usage:
     * <code>
     * $query->filterByDeductionValue(1234); // WHERE deduction_value = 1234
     * $query->filterByDeductionValue(array(12, 34)); // WHERE deduction_value IN (12, 34)
     * $query->filterByDeductionValue(array('min' => 12)); // WHERE deduction_value > 12
     * </code>
     *
     * @param     mixed $deductionValue The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesEstimatedBudgetsQuery The current query, for fluid interface
     */
    public function filterByDeductionValue($deductionValue = null, $comparison = null)
    {
        if (is_array($deductionValue)) {
            $useMinMax = false;
            if (isset($deductionValue['min'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::DEDUCTION_VALUE, $deductionValue['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($deductionValue['max'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::DEDUCTION_VALUE, $deductionValue['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesEstimatedBudgetsPeer::DEDUCTION_VALUE, $deductionValue, $comparison);
    }

    /**
     * Filter the query on the is_default column
     *
     * Example usage:
     * <code>
     * $query->filterByIsDefault(1234); // WHERE is_default = 1234
     * $query->filterByIsDefault(array(12, 34)); // WHERE is_default IN (12, 34)
     * $query->filterByIsDefault(array('min' => 12)); // WHERE is_default > 12
     * </code>
     *
     * @param     mixed $isDefault The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesEstimatedBudgetsQuery The current query, for fluid interface
     */
    public function filterByIsDefault($isDefault = null, $comparison = null)
    {
        if (is_array($isDefault)) {
            $useMinMax = false;
            if (isset($isDefault['min'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::IS_DEFAULT, $isDefault['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($isDefault['max'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::IS_DEFAULT, $isDefault['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesEstimatedBudgetsPeer::IS_DEFAULT, $isDefault, $comparison);
    }

    /**
     * Filter the query on the created column
     *
     * Example usage:
     * <code>
     * $query->filterByCreated('2011-03-14'); // WHERE created = '2011-03-14'
     * $query->filterByCreated('now'); // WHERE created = '2011-03-14'
     * $query->filterByCreated(array('max' => 'yesterday')); // WHERE created > '2011-03-13'
     * </code>
     *
     * @param     mixed $created The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesEstimatedBudgetsQuery The current query, for fluid interface
     */
    public function filterByCreated($created = null, $comparison = null)
    {
        if (is_array($created)) {
            $useMinMax = false;
            if (isset($created['min'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::CREATED, $created['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($created['max'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::CREATED, $created['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesEstimatedBudgetsPeer::CREATED, $created, $comparison);
    }

    /**
     * Filter the query on the modified column
     *
     * Example usage:
     * <code>
     * $query->filterByModified('2011-03-14'); // WHERE modified = '2011-03-14'
     * $query->filterByModified('now'); // WHERE modified = '2011-03-14'
     * $query->filterByModified(array('max' => 'yesterday')); // WHERE modified > '2011-03-13'
     * </code>
     *
     * @param     mixed $modified The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesEstimatedBudgetsQuery The current query, for fluid interface
     */
    public function filterByModified($modified = null, $comparison = null)
    {
        if (is_array($modified)) {
            $useMinMax = false;
            if (isset($modified['min'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::MODIFIED, $modified['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($modified['max'])) {
                $this->addUsingAlias(DamagesEstimatedBudgetsPeer::MODIFIED, $modified['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesEstimatedBudgetsPeer::MODIFIED, $modified, $comparison);
    }

    /**
     * Filter the query by a related DamagesCarDamages object
     *
     * @param   DamagesCarDamages|PropelObjectCollection $carDamages The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesEstimatedBudgetsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByCarDamages($carDamages, $comparison = null)
    {
        if ($carDamages instanceof DamagesCarDamages) {
            return $this
                ->addUsingAlias(DamagesEstimatedBudgetsPeer::CAR_DAMAGE_ID, $carDamages->getId(), $comparison);
        } elseif ($carDamages instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(DamagesEstimatedBudgetsPeer::CAR_DAMAGE_ID, $carDamages->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByCarDamages() only accepts arguments of type DamagesCarDamages or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the CarDamages relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesEstimatedBudgetsQuery The current query, for fluid interface
     */
    public function joinCarDamages($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('CarDamages');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'CarDamages');
        }

        return $this;
    }

    /**
     * Use the CarDamages relation CarDamages object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesCarDamagesQuery A secondary query class using the current class as primary query
     */
    public function useCarDamagesQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinCarDamages($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'CarDamages', 'DamagesCarDamagesQuery');
    }

    /**
     * Filter the query by a related DamagesAttachments object
     *
     * @param   DamagesAttachments|PropelObjectCollection $attachments The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesEstimatedBudgetsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByAttachments($attachments, $comparison = null)
    {
        if ($attachments instanceof DamagesAttachments) {
            return $this
                ->addUsingAlias(DamagesEstimatedBudgetsPeer::ATTACHMENT_ID, $attachments->getId(), $comparison);
        } elseif ($attachments instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(DamagesEstimatedBudgetsPeer::ATTACHMENT_ID, $attachments->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByAttachments() only accepts arguments of type DamagesAttachments or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the Attachments relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesEstimatedBudgetsQuery The current query, for fluid interface
     */
    public function joinAttachments($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('Attachments');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'Attachments');
        }

        return $this;
    }

    /**
     * Use the Attachments relation Attachments object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesAttachmentsQuery A secondary query class using the current class as primary query
     */
    public function useAttachmentsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinAttachments($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'Attachments', 'DamagesAttachmentsQuery');
    }

    /**
     * Exclude object from result
     *
     * @param   DamagesEstimatedBudgets $estimatedBudgets Object to remove from the list of results
     *
     * @return DamagesEstimatedBudgetsQuery The current query, for fluid interface
     */
    public function prune($estimatedBudgets = null)
    {
        if ($estimatedBudgets) {
            $this->addUsingAlias(DamagesEstimatedBudgetsPeer::ID, $estimatedBudgets->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }

}
